import Icon from '@ant-design/icons';
import { FloatButton } from 'antd';
import { useMemo } from 'react';
import originSvg from '../../icons/origin-position.svg?react';
import type { IconType } from '../index.d';
import styles from '../index.module.less';

const MapOrigin: React.FC<{
  onClick: () => void;
}> = (props) => {
  const { onClick } = props;

  const icons: IconType = useMemo(
    () => ({
      origin: <Icon component={originSvg} />,
    }),
    [],
  );

  return (
    <FloatButton
      className={styles.xdbtn}
      icon={icons.origin}
      shape="square"
      tooltip={{
        title: '回到当前位置',
        placement: 'left',
      }}
      onClick={() => {
        onClick();
      }}
    />
  );
};

export default MapOrigin;
